<?php

use Illuminate\Database\Seeder;

class OrdersTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $faker = app(\Faker\Generator::class);
        $users_openID = \App\Models\User::all()->pluck('openID')->toArray();
        $orders = factory(\App\Models\Order::class)
            ->times(50)
            ->make()
            ->each(function ($order,$index)
            use ($faker, $users_openID) {
                $order->provider = $faker->randomElement($users_openID);
            });
        $orders_array = $orders->toArray();
        \App\Models\Order::insert($orders_array);
    }
}
